<!DOCTYPE html>
<html>
    <head>
        <!-- 页面meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>畅购</title>
        <meta name="description" content="畅购">
        <meta name="keywords" content="畅购">
        <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
        <!-- 引入样式 -->
        <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" href="/css/style.css">
        <link rel="stylesheet" href="/plugins/elementui/index.css">
        <style>
            .el-dropdown-link {
                cursor: pointer;
                color: #409EFF;
            }
            .el-icon-arrow-down {
                font-size: 12px;
            }
        </style>
        <script src="/js/moment.min.js"></script>
    </head>
    <body class="hold-transition">
        <div id="app">
            <div class="content-header">
                <h4>订单列表</h4>
                <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                    <el-button><a href="javascript:void(0)" οnclick="location.reload()">刷新</a></el-button>
                    <!--<el-breadcrumb-item>预约管理</el-breadcrumb-item>-->
                </el-breadcrumb>
            </div>
            <div class="filter-container">
                <table>
                    <tr>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                        <td><el-tag type="success">全部订单</el-tag></td>
                        <td><el-tag type="success">待付款</el-tag></td>
                        <td><el-tag type="success">待发货</el-tag></td>
                        <td><el-tag type="success">已发货</el-tag></td>
                        <td><el-tag type="success">已完成</el-tag></td>
                        <td><el-tag type="success">已关闭</el-tag></td>
                    </tr>
                </table>
            </div>
            <div class="app-container">
                <div class="box">
                    <div class="filter-container">
                        <table>
                            <tr>
                                <td>筛选查询</td>
                                <td></td>
                                <td></td>
                                <td><button @click="findPage1()" class="dalfBut">查询结果</button></td>
                                <td><button>高级检索</button></td>
                            </tr>
                            <tr>
                                <td>输入搜索：<el-input placeholder="订单编号/商品货号" v-model="pagination.orderqueryString" style="width: 200px;" class="filter-item" ></el-input></td>
                                <td>收货人：<el-input placeholder="收货人姓名/手机号码" v-model="pagination.userqueryString" style="width: 200px;" class="filter-item">查询</el-input></td>
                                <td>
                                <el-td-column  style="width: 200px;" class="filter-item" >
                                <template>
                                <div class="block">
                                    <span class="demonstration">提交时间：</span>
                                    <el-date-picker
                                            v-model="pagination.pagetime"
                                            type="datetime"
                                            placeholder="选择日期时间">
                                    </el-date-picker>
                                </div>
                                </template>
                                </el-td-column>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div>
                        <table>
                        <td  width="60%"><template><i class="el-icon-s-operation"></i></template>数据列表</td>
                            <td></td>
                            <td><el-table-column><button>拆分订单</button></el-table-column></td>
                            <td><el-table-column><button>合并订单</button></el-table-column></td>
                            <td><el-table-column><button>批量发货</button></el-table-column></td>
                            选择文件<input type="text" v-model="fileName">
                            <el-button @click="exportExcel" type="success" size="mini" icon="el-icon-upload2">导出订单</el-button>
                            <td><el-dropdown @click="changePage()">
                                  <span class="el-dropdown-link">
                                    显示条数<i class="el-icon-arrow-down el-icon--right"></i>
                                  </span>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item  command="5">5</el-dropdown-item>
                                    <el-dropdown-item  command="10">10</el-dropdown-item>
                                    <el-dropdown-item  command="25">25</el-dropdown-item>
                                    <el-dropdown-item  command="50">50</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                            </td>
                            <td ><el-dropdown>
                                  <span class="el-dropdown-link">
                                    排序方式<i class="el-icon-arrow-down el-icon--right"></i>
                                  </span>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item>时间升序</el-dropdown-item>
                                    <el-dropdown-item>时间降序</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown></td>
                        </table>
                    <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                        <el-table-column type="selection" value="id" width="55"></el-table-column>
                        <el-table-column prop="id" label="订单编号" align="center"></el-table-column>
                        <el-table-column prop="createTime" label="提交时间" align="center">
                            <template slot-scope="scope">{{scope.row.createTime| dateFilter}}</template>
                        </el-table-column>
                        <el-table-column prop="username" label="用户账号" align="center"></el-table-column>
                        <el-table-column prop="payMoney" label="订单金额" align="center"></el-table-column>
                        <el-table-column prop="payType" label="支付方式" align="center">
                            <template slot-scope="scope">
                                <i v-if="scope.row.payType==='0'" class="el-icon-close">货到付款</i>
                                <i v-else class="el-icon-check">在线支付</i>
                            </template>
                        </el-table-column>
                        <el-table-column prop="sourceType" label="订单来源" align="center">
                            <template slot-scope="scope">
                                <i v-if="scope.row.sourceType=='1'" class="el-icon-close">web</i>
                                <i v-else class="el-icon-check">app</i>
                            </template>
                        </el-table-column>
                        <el-table-column prop="orderStatus" label="订单状态" align="center">
                            <template slot-scope="scope">
                                <i v-if="scope.row.orderStatus==='0'" class="el-icon-close">未支付</i>
                                <i v-else-if="scope.row.orderStatus==='1'" class="el-icon-close">已支付</i>
                                <i v-else-if="scope.row.orderStatus==='2'" class="el-icon-close">已发货</i>
                                <i v-else class="el-icon-check">已完成</i>
                            </template>
                        </el-table-column>
                        <el-table-column prop="orderStatus" label="操作" in-width="20%" align="center">
                            <template slot-scope="scope">
                                <el-button type="primary" size="mini" @click="checkOder(scope.row.id)">查看订单</el-button>
                                <el-button size="mini" v-if="scope.row.orderStatus==='0'" type="primary" @click="handleDelete(scope.row.id)">删除订单</el-button>
                                <el-button size="mini" v-else-if="scope.row.orderStatus==='1'" type="primary" @click="sendgoods(scope.row)">订单发货</el-button>
                                <el-button size="mini" v-else-if="scope.row.orderStatus==='2'" type="primary" @click="handleDelete(scope.row.id)">订单跟踪</el-button>
                                <el-button size="mini" v-else type="primary" @click="closeOrder(scope.row.id)">关闭订单</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    </div>
                    <div>
                    <div style="float: left">
                    <el-column type="selection" value="id" width="55">全选</el-column>&nbsp;&nbsp;&nbsp;
                    <el-button>关闭订单</el-button>
                    <el-button>删除订单</el-button>
                    </div>
                    <div class="pagination-container">
                        <el-pagination
                            class="pagiantion"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.currentPage"
                            :page-size="pagination.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="pagination.total">
                        </el-pagination>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <!-- 引入组件库 -->
    <script src="/js/vue.js"></script>
    <script src="/plugins/elementui/index.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script src="/js/axios-0.18.0.js"></script>

    <script>
        //过滤器
        Vue.filter("dateFilter",function (date,format) {
            return moment(date).format(format || "YYYY-MM-DD HH:mm:ss");
        });

        var vue = new Vue({
            el: '#app',
            data:{
                value:10,//选择分页数据
                pagination: {//分页相关模型数据
					  currentPage: 1,//当前页码
					  pageSize:10,//每页显示的记录数
					  total:0,//总记录数
					  orderqueryString:null,//查询条件
					  userqueryString:null,//查询条件
                      pagetime:null,//时间
                      fileName: ''
				},
				dataList: [],//当前页要展示的分页列表数据

            },
            //钩子函数，VUE对象初始化完成后自动执行
            created() {
                this.findPage();
            },
            methods: {
                //导出订单到excel表中
                exportExcel(){
                    alert(this.fileName);
                    var param={
                        filename:this.fileName,
                        list:this.dataList
                    }
                    //+fileName,this.dataList
                    axios.post("/worder/exportexcel",param).then(res=>{
                        if (res.data.flag){
                            alert(res.data.message);
                        }
                    })
                },
                //关闭订单
                closeOrder(id){
                    axios.get("/worder/closeorder?id=",order).then(res=>{
                        if (res.data.flag){
                            alert(res.data.message);
                        }
                    })
                },
                //发货
                sendgoods(order){
                    alert(123)
                    /*axios.post("/worder/sendgoods",order).then(res=>{
                        if (res.data.flag){
                            alert(res.data.message);
                            this.findPage();
                        }
                    })*/
                },
                //查看订单
                checkOder(id){
                    axios.get("/worder/findByid?id="+id).then(res=>{
                        if (res.data.flag){
                            this.dataList=res.data.data;
                        }
                    })
                },
                //删除订单
                handleDelete(id){
                    axios.delete("/worder/deletByid/"+id).then(res=>{
                        if (res.data.flag){
                            alert(res.data.message);
                            this.findPage();
                        }
                    })
                },
                //选择每页显示条数
                changePage(command){
                    alert("页数:"+command);
                    this.pagination.currentPage=command;
                },
                //翻页
                handleCurrentChange(){
                    this.findPage();
                },
                //模糊查询
                findPage1(){
                    this.pagination.currentPage=1;
                    this.findPage();
                },
                //分页查询
                findPage() {
                    //发送ajax请求，提交参数（页码，每页显示记录数，查询条件）
                    var param={
                        page:this.pagination.currentPage,
                        size:this.pagination.pageSize,
                        id: this.pagination.orderqueryString,
                        username: this.pagination.userqueryString,
                        createTime:this.pagination.pagetime
                    }
                    axios.post("/worder/orderlist/"+this.pagination.currentPage+"/"+this.pagination.pageSize,param).then((res)=>{
                        if (res.data.flag) {
                            console.log(this.pagination.currentPage)
                            this.dataList = res.data.data.rows;
                            this.pagination.total = res.data.data.total;
                        }
                    });
                },
            },
            created:function () {
                this.findPage();
            }
        })
    </script>
</html>